package com.teapos.enumtype;

public enum Unit4SaveEnum {
	
	PIAN(0, "散装", "片"),
	JIAN(1, "整装", "件"),
	TONG(2, "筒装", "筒");
	
	private int code;
	private String desc;
	private String name;
	private Unit4SaveEnum(int code, String desc, String name) {
		this.code = code;
		this.desc = desc;
		this.name = name;
	}
	public int getCode() {
		return code;
	}
	public void setCode(int code) {
		this.code = code;
	}
	public String getDesc() {
		return desc;
	}
	public void setDesc(String desc) {
		this.desc = desc;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public static Unit4SaveEnum getEnumByCode(int code) {
		Unit4SaveEnum[] enums = Unit4SaveEnum.values();
		for(Unit4SaveEnum enumtype:enums) {
			if(enumtype.getCode()==code) return enumtype;
		}
		return null;
	}
	public static Unit4SaveEnum getEnumByDesc(String desc) {
		Unit4SaveEnum[] enums = Unit4SaveEnum.values();
		for(Unit4SaveEnum enumtype:enums) {
			if(enumtype.getDesc().equals(desc)) return enumtype;
		}
		return null;
	}
	public static Unit4SaveEnum getEnumByName(String name) {
		Unit4SaveEnum[] enums = Unit4SaveEnum.values();
		for(Unit4SaveEnum enumtype:enums) {
			if(enumtype.getName().equals(name)) return enumtype;
		}
		return null;
	}

}
